const AipOcrClient = require("baidu-aip-sdk").ocr;
const fs = require("fs");

const APP_ID = "19954914";
const API_KEY = "kQxFxXWCiUyfLV3F4xG8iKjF";
const SECRET_KEY = "WuXwB5px5eDryHqSSPDwqCLZevkQBIQh";

// 新建一个对象，建议只保存一个对象调用服务接口
let client = new AipOcrClient(APP_ID, API_KEY, SECRET_KEY);

// 如果有可选参数
var options = {};
// options["language_type"] = "CHN_ENG"; //语言可选
options["detect_direction"] = "true";  //检查朝向
// options["detect_language"] = "true"; //检测语言
// options["probability"] = "true"; //置信度
// 调用营业执照识别
function business(base64Img) {
    client.businessLicense(base64Img, options).then(function (result) {
        return JSON.stringify(result.words_result);
    }).catch(function (err) {
        // 如果发生网络错误
        console.log(err);
    });
}
//行驶证
function vehicle(base64Img) {
    client.vehicleLicense(base64Img, options).then(function (result) {
        return JSON.stringify(result.words_result)
    }).catch(function (err) {
        // 如果发生网络错误
        console.log(err);
    });
}



module.exports = { business, vehicle }